//
//  WXMagicNumber.h
//  数字变化动效
//
//  Created by tianlong on 2018/6/5.
//  Copyright © 2018年 tianlong. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef NS_ENUM(NSUInteger, MagicAnimationType) {
    /** 由慢到快,再由快到慢*/
    MagicAnimationTypeEaseInOut = 1,
    /** 由慢到快*/
    MagicAnimationTypeEaseIn,
    /** 由快到慢*/
    MagicAnimationTypeEaseOut,
    /** 匀速*/
    MagicAnimationTypeLinear
};

typedef NS_ENUM(NSUInteger, MagicAnimationStyle) {

    MagicAnimationStyleNone = 1,
    /** 滚动 */
    MagicAnimationStyleRoll,
};

/** 指向动画效果的计算函数 */
typedef CGFloat (*BufferFunction)(CGFloat);

@interface WXMagicNumber : NSObject

/**
 数字滚动
 @param toNumber 从0开始到结束数字
 @param type 动画类型
 @param duration 动画持续时长
 @param progressBlock 执行进度
 */
- (void)animation_rollToNumber:(CGFloat)toNumber
                 animationType:(MagicAnimationType)type
                      duration:(CFTimeInterval)duration
                 progressBlock:(void (^)(CGFloat number,CGFloat percent))progressBlock;
/**
 数字滚动
 @param fromNumber 开始数字
 @param toNumber 结束数字
 @param type 动画类型
 @param duration 动画持续时长
 @param progressBlock 执行进度
 */
- (void)animation_rollFromNumber:(CGFloat)fromNumber
                        toNumber:(CGFloat)toNumber
                   animationType:(MagicAnimationType)type
                        duration:(CFTimeInterval)duration
                   progressBlock:(void (^)(CGFloat number,CGFloat percent))progressBlock;
+ (instancetype)number;
@end
